package com.yanqu.road.logic.activity.horserun;

import com.yanqu.road.dao.impl.activity.horserun.HorseRunConfigImpl;
import com.yanqu.road.entity.activity.ActivityConfig;
import com.yanqu.road.entity.activity.ActivityInfo;
import com.yanqu.road.entity.activity.horserun.HorseRunUserGamingData;
import com.yanqu.road.entity.activity.horserun.config.*;
import com.yanqu.road.entity.enums.activity.horserun.eHorseRunAttrEnum;
import com.yanqu.road.entity.enums.activity.horserun.eHorseRunEventType;
import com.yanqu.road.entity.enums.activity.horserun.eHorseRunRacingZoneEnum;
import com.yanqu.road.logic.activity.UpLowLimitEntity;
import com.yanqu.road.logic.helper.WeightHelper;
import com.yanqu.road.utils.date.DateHelper;
import com.yanqu.road.utils.string.StringUtils;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;

public class HorseRunConfig {

    private ActivityInfo activityInfo;

    private Random random;
    //-------------------表配置-------------------------
    //装备
    Map<Integer, HorseRunEquipConfig> equipConfigs;
    //事件
    Map<Integer, HorseRunEventConfig> eventConfigs;
    //等级
    Map<Integer, HorseRunLevelConfig> levelConfigs;
    //马场
    Map<Integer, HorseRunRaceCourseConfig> courseConfigMap;
    //技能
    Map<Integer, HorseRunSkillConfig> skillConfigs;
    //转盘
    Map<Integer, HorseRunTurnTableConfig> turnTableConfigs;
    //转盘的权重map
    Map<Integer,Integer> turnTableWeightMap;



    //文本
    Map<Integer, HorseRunTextConfig> textConfigs;

    //boss Attr
    Map<Integer,HorseRunBossConfig> bossConfigMap;

    //boss name
    Map<Integer,HorsRunBossNameConfig> bossNameConfigMap;

    //随机boss外观list
    List<Integer> randomAppearanceList;

    //事件类型上限map
    Map<Integer,Integer> typeLimitMap;

    //经验事件权重map
    Map<Integer,Integer> expSignalEventWeightMap;

    //7.5新增优化 需要回收的道具
    List<Integer> needRecycleItemList;



    //-------------------config的配置----------------------

    //冒险干粮id 开冒险用的
    private int openAdventureItem;
    //词条刷新道具id
    private int refreshEntryItem;
    //每x级获得一个新的技能孔
//    private int skillHoleAddNeedLevel;
    //初始属性
//    private String initAttribute;
    //初始属性Map
//    private Map<Integer,Integer> initAttributeMap;
    //加点固定提升属性
    private int attrPointPerLevelAddAttr;
    //几分钟产出一次经验
    private int expOutPutNeedMinute;
    //初始信心 (血量值) 没了就死
    private int initConfidence;
    //一个阶段有x关，最后一关必定为固定战斗
    private int stagePerProcess;
    //第一关必刷事件id
//    private int stage1Event;
    //经验事件单独权重 先随机出来干到一个阶段里面 其他的走随机
    private String expEventWeight;
    //上面那个的map
    private Map<Integer, Integer> expEventNumWeightMap;

    //大吉转盘需要多少大吉事件才能触发
    private int bigLuckyLotteryNeedBigLuckyTime;

    //探索事件最多探索次数
    private int exploreEventMaxTime;

    //技能孔最多刷新次数
    private int refreshSkillMaxTimesPosition;

    //技能刷新消耗道具递增
    private String refreshSkillItemCostAdd;
    //技能消耗递增map
    private Map<Integer,Integer> refreshCostItemAddMap;

    //元宝消耗递增
    private String refreshIngotAdd;
    //元宝消耗递增map
    private Map<Integer,Integer> refreshIngotAddMap;

    //洗属性点道具
    private int refreshAttrPointItem;
    //洗属性点道具消耗递增
    private String refreshAttrCostAdd;
    //洗属性点道具消耗递增map
    private Map<Integer,Integer> refreshAttrPointCostAddMap;

    //小马快跑商会马场展示商会小马数量
    private int showUnionHorseNum;

    //小马快跑开启道路选择需要冒险次数
    private int openDiffRoadNeedTimeTime;


    //------------------------------小马赛道
    //精力赛道速度算法 类型1的赛道
    private String energyTrackAttrAdd;
    //精力赛道速度算法map
    private Map<Integer,Integer>energyTrackAttrAddMap;
    //技巧赛道速度算法 类型2的赛道
    private String artfulTrackAttrAdd;
    //技巧赛道速度算法map
    private Map<Integer,Integer>artfulTrackAttrAddMap;
    //抗性赛道速度算法 类型3赛道
    private String resistanceTrackAttrAdd;
    //抗性赛道速度算法map
    private Map<Integer,Integer>resistanceTrackAttrAddMap;
    //赛场奖牌积分（除了参与奖 排名上限;排名下限,积分）
    private String trackScoreAdd;
    //赛场奖牌积分 Map<第几天,List<上下限>>
    private Map<Integer,List<UpLowLimitEntity>> dayRacingScoreMap;

    //玄武赛道各跑道数量
    private String xuanWu4TrackDistribution;
    //玄武赛道各跑道数量Map
    private Map<Integer,List<Integer>> xuanWu4TrackDistributionMap;
    //朱雀赛道各跑道数量
    private String zhuQue3TrackDistribution;
    //朱雀赛道各跑道数量Map
    private Map<Integer,List<Integer>> zhuQue3TrackDistributionMap;

    //白虎赛道各跑道数量
    private String baiHu2TrackDistribution;
    //白虎赛道各跑道数量Map
    private Map<Integer,List<Integer>> baiHu2TrackDistributionMap;

    //青龙赛道各跑道数量
    private String qingLong1TrackDistribution;
    //青龙赛道各跑道数量Map
    private Map<Integer,List<Integer>> qingLong1TrackDistributionMap;

    //赛道长度倍率 总长度=上面的跑道数量*长度倍率
    private int trackLengthRate;

    //赛道随机分段数量
    private String randomTrackSegmentation;
    //赛道随机分段数量map
    private Map<Integer,List<Integer>> randomTrackSegmentationMap;

    //开启一次道具消耗(累计使用道具数量;开启倍率|累计使用道具数量;开启倍率）
    private String openItemNumCostNeedUsed;
    //开启一次道具消耗列表(累计使用道具数量;开启倍率|累计使用道具数量;开启倍率）
    private Map<Integer,Integer> openItemNeedCostedNumMap;

    //商会马场比赛时间（报名期开始时间|报名期结束时间|等待开赛结束时间|进行比赛结束时间）单位 分钟
    private String openRacingTime;
    //商会马场比赛时间列表（报名期开始时间|报名期结束时间|等待开赛结束时间|进行比赛结束时间）单位 分钟
    private List<Integer> openRacingTimeList;
    //排行榜上限
    private int rankMaxNum;
    //三个属性赛道的总和数量
    private int racingRoadTotalNum;
    //重新选择赛道冷却时间
    private int racingChooseResetTime;


    public HorseRunConfig(ActivityInfo activityInfo, Map<String, ActivityConfig> activityConfigMap) {
        this.activityInfo = activityInfo;
        int activityId = activityInfo.getActivityId();

        this.equipConfigs = new HorseRunConfigImpl().getHorseRunEquipConfigMap(activityId);
        this.eventConfigs = new HorseRunConfigImpl().getHorseRunEventConfigMap(activityId);
        this.levelConfigs = new HorseRunConfigImpl().getHorseRunLevelConfigMap(activityId);
        this.courseConfigMap = new HorseRunConfigImpl().getHorseRunRaceCourseConfigList(activityId);
        this.skillConfigs = new HorseRunConfigImpl().getHorseRunSkillConfigList(activityId);
        this.turnTableConfigs = new HorseRunConfigImpl().getHorseRunTurnTableConfigList(activityId);
        this.textConfigs = new HorseRunConfigImpl().getHorseRunTextConfigMap(activityId);
        this.bossConfigMap = new HorseRunConfigImpl().getHorseRunBossConfigMap(activityId);
        this.bossNameConfigMap = new HorseRunConfigImpl().getHorsRunBossNameConfigMap(activityId);

        this.openAdventureItem = activityConfigMap.get("FOOD_ITEM_ID").getIntValue();
        this.refreshEntryItem = activityConfigMap.get("REFRESH_ITEM_ID").getIntValue();
//        this.skillHoleAddNeedLevel = activityConfigMap.get("SKILL_UPGRADE_NUM").getIntValue();
        this.showUnionHorseNum = activityConfigMap.get("RECECOURSE_SHOW_HORSE").getIntValue();

//        this.initAttribute = activityConfigMap.get("INITIAL_ATTRIBUTE").getValue();
//        List<Integer> initAttrList = StringUtils.stringToIntegerList(this.initAttribute, "\\|");
//        Map<Integer,Integer> tempAttrInit = new HashMap<>();
//        tempAttrInit.put(eHorseRunAttrEnum.energy.getValue(),initAttrList.get(0));
//        tempAttrInit.put(eHorseRunAttrEnum.artful.getValue(),initAttrList.get(1));
//        tempAttrInit.put(eHorseRunAttrEnum.resistance.getValue(),initAttrList.get(2));
//        this.initAttributeMap = tempAttrInit;

        this.attrPointPerLevelAddAttr = activityConfigMap.get("LEVEL_ATTRIBUTE_UP").getIntValue();
        this.expOutPutNeedMinute = activityConfigMap.get("RECECOURSE_EXP_TIME").getIntValue();
        this.initConfidence = activityConfigMap.get("INITIAL_CONFIDENCE").getIntValue();
        this.stagePerProcess = activityConfigMap.get("STAGE_NUM").getIntValue();
//        this.stage1Event = activityConfigMap.get("LEVEL1_EVENT").getIntValue();

        this.expEventWeight = activityConfigMap.get("EXPEVENT_WEIGHT").getValue();
        List<String> expWeight = StringUtils.stringToStringList(expEventWeight, "\\|");
        Map<Integer,Integer> tempExpEventWeightMap = new HashMap<>();
        for (String str : expWeight) {
            List<Integer> integers = StringUtils.stringToIntegerList(str, ";");
            tempExpEventWeightMap.put(integers.get(0), integers.get(1));
        }
        this.expEventNumWeightMap = tempExpEventWeightMap;

        this.bigLuckyLotteryNeedBigLuckyTime = activityConfigMap.get("TURNTABLE_NEED_NUM").getIntValue();
        this.exploreEventMaxTime = activityConfigMap.get("EXPLORE_EVENT_NUM").getIntValue();

        this.energyTrackAttrAdd = activityConfigMap.get("ENERGY_TRACK_FORMULA").getValue();
        Map<Integer,Integer> tempEnergyTrackMap = new HashMap<>();
        List<Integer> energyTrackAttr = StringUtils.stringToIntegerList(energyTrackAttrAdd, "\\|");
        tempEnergyTrackMap.put(eHorseRunAttrEnum.energy.getValue(),energyTrackAttr.get(0));
        tempEnergyTrackMap.put(eHorseRunAttrEnum.artful.getValue(),energyTrackAttr.get(1));
        tempEnergyTrackMap.put(eHorseRunAttrEnum.resistance.getValue(),energyTrackAttr.get(2));
        this.energyTrackAttrAddMap = tempEnergyTrackMap;

        this.artfulTrackAttrAdd = activityConfigMap.get("ARTFUL_TRACK_FORMULA").getValue();
        Map<Integer,Integer> tempArtfulTrackMap = new HashMap<>();
        List<Integer> artfulTrackAttr = StringUtils.stringToIntegerList(artfulTrackAttrAdd, "\\|");
        tempArtfulTrackMap.put(eHorseRunAttrEnum.energy.getValue(),artfulTrackAttr.get(0));
        tempArtfulTrackMap.put(eHorseRunAttrEnum.artful.getValue(),artfulTrackAttr.get(1));
        tempArtfulTrackMap.put(eHorseRunAttrEnum.resistance.getValue(),artfulTrackAttr.get(2));
        this.artfulTrackAttrAddMap = tempArtfulTrackMap;

        this.resistanceTrackAttrAdd = activityConfigMap.get("RESISTANCE_TRACK_FORMULA").getValue();
        Map<Integer,Integer> tempResistanceTrackMap = new HashMap<>();
        List<Integer> resistanceTrackAttr = StringUtils.stringToIntegerList(resistanceTrackAttrAdd, "\\|");
        tempResistanceTrackMap.put(eHorseRunAttrEnum.energy.getValue(),resistanceTrackAttr.get(0));
        tempResistanceTrackMap.put(eHorseRunAttrEnum.artful.getValue(),resistanceTrackAttr.get(1));
        tempResistanceTrackMap.put(eHorseRunAttrEnum.resistance.getValue(),resistanceTrackAttr.get(2));
        this.resistanceTrackAttrAddMap = tempResistanceTrackMap;

        this.trackScoreAdd = activityConfigMap.get("RECECOURSE_REWARD_SCORE").getValue();
        Map<Integer,List<UpLowLimitEntity>> tempTrackScoreMap = new HashMap<>();
        List<String> trackScoreDayStringList = StringUtils.stringToStringList(trackScoreAdd, "#");
        int dayRacingScoreNo = 1;
        for (String dayString : trackScoreDayStringList) {
            List<UpLowLimitEntity> tempLimitEneityList = new ArrayList<>();
            List<String> trackScoreList = StringUtils.stringToStringList(dayString, "\\|");
            for (String str : trackScoreList) {
                List<String> strings = StringUtils.stringToStringList(str, ";");
                int low = Integer.parseInt(strings.get(0));
                String s = strings.get(1);
                List<Integer> integers = StringUtils.stringToIntegerList(s, ",");
                int high = integers.get(0);
                long value = integers.get(1);
                UpLowLimitEntity entity = new UpLowLimitEntity(low,high,value);
                tempLimitEneityList.add(entity);
            }
            tempTrackScoreMap.put(dayRacingScoreNo,tempLimitEneityList);
            dayRacingScoreNo++;
        }


        this.dayRacingScoreMap = tempTrackScoreMap;

        this.xuanWu4TrackDistribution = activityConfigMap.get("XUANWU_ROAD").getValue();
        Map<Integer,List<Integer>> tempXuanWuTrack1DistributionMap = new HashMap<>();
        List<String> xuanwuRoadList = StringUtils.stringToStringList(xuanWu4TrackDistribution, "\\|");
        int trackId = 1;
        for (String str : xuanwuRoadList) {
            List<Integer> integers = StringUtils.stringToIntegerList(str, ";");
            tempXuanWuTrack1DistributionMap.put(trackId, integers);
            trackId++;
        }
        this.xuanWu4TrackDistributionMap = tempXuanWuTrack1DistributionMap;

        this.zhuQue3TrackDistribution = activityConfigMap.get("ZHUQUE_ROAD").getValue();
        Map<Integer,List<Integer>> tempZhuQueTrack1DistributionMap = new HashMap<>();
        List<String> zhuqueRoadList = StringUtils.stringToStringList(zhuQue3TrackDistribution, "\\|");
        trackId = 1;
        for (String str : zhuqueRoadList) {
            List<Integer> integers = StringUtils.stringToIntegerList(str, ";");
            tempZhuQueTrack1DistributionMap.put(trackId, integers);
            trackId++;
        }
        this.zhuQue3TrackDistributionMap = tempZhuQueTrack1DistributionMap;

        this.baiHu2TrackDistribution = activityConfigMap.get("BAIHU_ROAD").getValue();
        Map<Integer,List<Integer>> tempBaihuTrackDistributionMap = new HashMap<>();
        List<String> baihuRoadList = StringUtils.stringToStringList(baiHu2TrackDistribution, "\\|");
        trackId = 1;
        for (String str : baihuRoadList) {
            List<Integer> integers = StringUtils.stringToIntegerList(str, ";");
            tempBaihuTrackDistributionMap.put(trackId, integers);
            trackId++;
        }
        this.baiHu2TrackDistributionMap = tempBaihuTrackDistributionMap;

        this.qingLong1TrackDistribution = activityConfigMap.get("QINGLONG_ROAD").getValue();
        Map<Integer,List<Integer>> qingLongTrackDistributionMap = new HashMap<>();
        List<String> qinglongRoadList = StringUtils.stringToStringList(qingLong1TrackDistribution, "\\|");
        trackId = 1;
        for (String str : qinglongRoadList) {
            List<Integer> integers = StringUtils.stringToIntegerList(str, ";");
            qingLongTrackDistributionMap.put(trackId, integers);
            trackId++;
        }
        this.qingLong1TrackDistributionMap = qingLongTrackDistributionMap;
        
        this.trackLengthRate = activityConfigMap.get("ROAD_LENGTH_UNIT").getIntValue();

        this.randomTrackSegmentation = activityConfigMap.get("ROAD_RANDOM_LENGTH").getValue();
        Map<Integer,List<Integer>> tempTrackDispatchMap = new HashMap<>();
        trackId = 1;
        List<String> strings = StringUtils.stringToStringList(randomTrackSegmentation, "\\|");
        for (String str : strings) {
            List<Integer> integers = StringUtils.stringToIntegerList(str, ";");
            tempTrackDispatchMap.put(trackId, integers);
            trackId++;
        }
        this.randomTrackSegmentationMap = tempTrackDispatchMap;

        this.openItemNumCostNeedUsed = activityConfigMap.get("START_LEVEL_NUM").getValue();
        Map<Integer,Integer> tempUsedMap=new HashMap<>();
        List<String> costNeedList = StringUtils.stringToStringList(this.openItemNumCostNeedUsed, "\\|");
        for (String str : costNeedList) {
            List<Integer> cost = StringUtils.stringToIntegerList(str, ";");
            tempUsedMap.put(cost.get(1), cost.get(0));
        }
        this.openItemNeedCostedNumMap = tempUsedMap;

        this.openRacingTime = activityConfigMap.get("PVP_RACE_TIME").getValue();
        this.openRacingTimeList = StringUtils.stringToIntegerList(this.openRacingTime, "\\|");

        this.randomAppearanceList = new ArrayList<>(this.bossNameConfigMap.keySet());

        Map<Integer,Integer> tempTypeLimitMap = new HashMap<>();
        Map<Integer,Integer> tempExpSignalEventWeightMap = new HashMap<>();
        for (HorseRunEventConfig eventConfig:eventConfigs.values()) {
            eventConfig.setParamList(StringUtils.stringToIntegerList(eventConfig.getParam(),"\\|"));

            if (eventConfig.getAllMax()>0){
                tempTypeLimitMap.put(eventConfig.getType(),eventConfig.getAllMax());
            }
            if (eventConfig.getType()==eHorseRunEventType.exp.getValue()){
                tempExpSignalEventWeightMap.put(eventConfig.getId(),eventConfig.getWeight());
            }

        }
        this.typeLimitMap = tempTypeLimitMap;
        this.expSignalEventWeightMap = tempExpSignalEventWeightMap;
//        this.refreshSkillMaxTimesPosition = activityConfigMap.get("SKILL_REFRESH_MAX_NUM").getIntValue();

        this.refreshSkillItemCostAdd = activityConfigMap.get("SKILL_REFRESH_COST_NUM").getValue();
        List<String> refreshSkillAdd = StringUtils.stringToStringList(this.refreshSkillItemCostAdd, ";");
        Map<Integer,Integer> costAddMap = new HashMap<>();
        for (String str : refreshSkillAdd) {
            List<Integer> integers = StringUtils.stringToIntegerList(str, ",");
            costAddMap.put(integers.get(0), integers.get(1));
        }
        this.refreshCostItemAddMap = costAddMap;

        this.refreshIngotAdd = activityConfigMap.get("SKILL_REFRESH_COST_YUANBAO_NUM").getValue();
        List<String> tempIngotAdd = StringUtils.stringToStringList(this.refreshIngotAdd, ";");
        Map<Integer,Integer> tempIngotCostAddMap = new HashMap<>();
        for (String str : tempIngotAdd) {
            List<Integer> integers = StringUtils.stringToIntegerList(str, ",");
            tempIngotCostAddMap.put(integers.get(0), integers.get(1));
        }
        this.refreshIngotAddMap = tempIngotCostAddMap;


        Map<Integer,Integer>tempTurnWeightMap = new HashMap<>();
        for (HorseRunTurnTableConfig turnTableConfig:this.getTurnTableConfigs().values()){
            tempTurnWeightMap.put(turnTableConfig.getId(), turnTableConfig.getWeight());
        }
        this.turnTableWeightMap = tempTurnWeightMap;

        this.rankMaxNum = activityConfigMap.get("RECECOURSE_RANK_MAX_NUM").getIntValue();

        this.refreshAttrPointItem = activityConfigMap.get("LEVEL_REFRESH_ITEM_ID").getIntValue();
        this.refreshAttrCostAdd = activityConfigMap.get("LEVEL_REFRESH_COST_NUM").getValue();

        Map<Integer,Integer> tempAttrRefreshCostAddMap = new HashMap<>();
        List<String> tempRefreshAttrCost = StringUtils.stringToStringList(this.refreshAttrCostAdd, ";");
        for (String str : tempRefreshAttrCost) {
            List<Integer> integers = StringUtils.stringToIntegerList(str, ",");
            tempAttrRefreshCostAddMap.put(integers.get(0), integers.get(1));
        }
        this.refreshAttrPointCostAddMap = tempAttrRefreshCostAddMap;

        this.racingRoadTotalNum = activityConfigMap.get("ROAD_TOTAL_LONG").getIntValue();

        this.openDiffRoadNeedTimeTime = activityConfigMap.get("SELECT_NEED_NUM").getIntValue();

        this.racingChooseResetTime = activityConfigMap.get("RACE_RESET_TIME").getIntValue();

        random = new Random();

        //7.5新增 需要回收的小马皮
        if (activityConfigMap.containsKey("HORSE_CLOTHES_RECLAIM")){
            needRecycleItemList = StringUtils.stringToIntegerList(activityConfigMap.get("HORSE_CLOTHES_RECLAIM").getValue(), "\\|");
        }else {
            needRecycleItemList = new ArrayList<>();
        }

    }


    public ActivityInfo getActivityInfo() {
        return activityInfo;
    }

    public int getOpenAdventureItem() {
        return openAdventureItem;
    }

    public int getRefreshEntryItem() {
        return refreshEntryItem;
    }

//    public int getSkillHoleAddNeedLevel() {
//        return skillHoleAddNeedLevel;
//    }

//    public String getInitAttribute() {
//        return initAttribute;
//    }
//
//    public Map<Integer, Integer> getInitAttributeMap() {
//        return initAttributeMap;
//    }

    public int getAttrPointPerLevelAddAttr() {
        return attrPointPerLevelAddAttr;
    }

    public int getExpOutPutNeedMinute() {
        return expOutPutNeedMinute;
    }

    public int getInitConfidence() {
        return initConfidence;
    }

    public int getStagePerProcess() {
        return stagePerProcess;
    }

//    public int getStage1Event() {
//        return stage1Event;
//    }

    public String getExpEventWeight() {
        return expEventWeight;
    }

    public Map<Integer, Integer> getExpEventNumWeightMap() {
        return expEventNumWeightMap;
    }

    public int getBigLuckyLotteryNeedBigLuckyTime() {
        return bigLuckyLotteryNeedBigLuckyTime;
    }

    public String getEnergyTrackAttrAdd() {
        return energyTrackAttrAdd;
    }

    public Map<Integer, Integer> getEnergyTrackAttrAddMap() {
        return energyTrackAttrAddMap;
    }

    public String getArtfulTrackAttrAdd() {
        return artfulTrackAttrAdd;
    }

    public Map<Integer, Integer> getArtfulTrackAttrAddMap() {
        return artfulTrackAttrAddMap;
    }

    public String getResistanceTrackAttrAdd() {
        return resistanceTrackAttrAdd;
    }

    public Map<Integer, Integer> getResistanceTrackAttrAddMap() {
        return resistanceTrackAttrAddMap;
    }

    public String getTrackScoreAdd() {
        return trackScoreAdd;
    }

    public Map<Integer, List<UpLowLimitEntity>> getDayRacingScoreMap() {
        return dayRacingScoreMap;
    }

    public String getXuanWu4TrackDistribution() {
        return xuanWu4TrackDistribution;
    }

 

    public String getZhuQue3TrackDistribution() {
        return zhuQue3TrackDistribution;
    }

    public String getBaiHu2TrackDistribution() {
        return baiHu2TrackDistribution;
    }

   

    public String getQingLong1TrackDistribution() {
        return qingLong1TrackDistribution;
    }

   

    public int getTrackLengthRate() {
        return trackLengthRate;
    }

    public String getRandomTrackSegmentation() {
        return randomTrackSegmentation;
    }

    public int getExploreEventMaxTime() {
        return exploreEventMaxTime;
    }

    public Map<Integer, List<Integer>> getXuanWu4TrackDistributionMap() {
        return xuanWu4TrackDistributionMap;
    }

    public Map<Integer, List<Integer>> getZhuQue3TrackDistributionMap() {
        return zhuQue3TrackDistributionMap;
    }

    public Map<Integer, List<Integer>> getBaiHu2TrackDistributionMap() {
        return baiHu2TrackDistributionMap;
    }

    public Map<Integer, List<Integer>> getQingLong1TrackDistributionMap() {
        return qingLong1TrackDistributionMap;
    }

    public Map<Integer, List<Integer>> getRandomTrackSegmentationMap() {
        return randomTrackSegmentationMap;
    }

    public List<Integer> getTrackSegmentationById(int attrType){
        return randomTrackSegmentationMap.get(attrType);
    }

    public int getActivityId(){
        return activityInfo.getActivityId();
    }

    public Map<Integer, HorseRunEquipConfig> getEquipConfigs() {
        return equipConfigs;
    }

    public Map<Integer, HorseRunEventConfig> getEventConfigs() {
        return eventConfigs;
    }

    public Map<Integer, HorseRunLevelConfig> getLevelConfigs() {
        return levelConfigs;
    }

    public Map<Integer, HorseRunRaceCourseConfig> getCourseConfigMap() {
        return courseConfigMap;
    }

    public Map<Integer, HorseRunSkillConfig> getSkillConfigs() {
        return skillConfigs;
    }

    public Map<Integer, HorseRunTurnTableConfig> getTurnTableConfigs() {
        return turnTableConfigs;
    }

    public Map<Integer, HorseRunTextConfig> getTextConfigs() {
        return textConfigs;
    }

    public HorseRunEventConfig getEventConfigById(int eventId) {
        return eventConfigs.get(eventId);
    }

    public HorseRunLevelConfig getLevelConfigById(int levelId) {
        return levelConfigs.get(levelId);
    }

    public HorseRunRaceCourseConfig getCourseConfigById(int courseId) {
        return courseConfigMap.get(courseId);
    }

    public HorseRunSkillConfig getSkillConfigById(int skillId) {
        return skillConfigs.get(skillId);
    }

    public HorseRunTurnTableConfig getTurnTableConfigById(int turnTableId) {
        return turnTableConfigs.get(turnTableId);
    }
    public HorseRunTextConfig getTextConfigById(int textId) {
        return textConfigs.get(textId);
    }

    public HorseRunEquipConfig getEquipConfigById(int equipId) {
        return equipConfigs.get(equipId);
    }

    public String getOpenItemNumCostNeedUsed() {
        return openItemNumCostNeedUsed;
    }

    public Map<Integer, Integer> getOpenItemNeedCostedNumMap() {
        return openItemNeedCostedNumMap;
    }

    public String getOpenRacingTime() {
        return openRacingTime;
    }

    public List<Integer> getOpenRacingTimeList() {
        return openRacingTimeList;
    }

    public int getMultiOpenNeedUsed(int multiNum){
        if (multiNum == 1){
            return 0;
        }

        if (openItemNeedCostedNumMap.containsKey(multiNum)){
            return openItemNeedCostedNumMap.get(multiNum);
        }
        return -1;
    }



    public int getRandomExploreEventId(){
        Map<Integer,Integer> weightMap = new HashMap<>();
        for (HorseRunEventConfig eventConfig:eventConfigs.values()){
            if (eventConfig.getType() == eHorseRunEventType.exploreChild.getValue()){
                weightMap.put(eventConfig.getId(),eventConfig.getWeight());
            }
        }
        return WeightHelper.getRandomValue(weightMap);
    }

    public int randomBattleHorseAppearance(){
        int index = random.nextInt(randomAppearanceList.size());
        return randomAppearanceList.get(index);
    }

    public Random getRandom() {
        return random;
    }

    public Map<Integer, HorseRunBossConfig> getBossConfigMap() {
        return bossConfigMap;
    }

    public Map<Integer, HorsRunBossNameConfig> getBossNameConfigMap() {
        return bossNameConfigMap;
    }

    public List<Integer> getRandomAppearanceList() {
        return randomAppearanceList;
    }

    public HorseRunBossConfig getThisProcessBossConfig(int process){
        return bossConfigMap.get(process+1);
    }

    public HorseRunBossConfig getLastProcessBossConfig(int process){
        return bossConfigMap.get(process);
    }

    public static void main(String[] args) {
        List<Integer> ss = new ArrayList<>();
        ss.add(1);
        ss.add(2);
        ss.add(3);
        ss.add(4);
        List<Integer> newLis = ss.subList(3,ss.size());
        System.out.println(ss);
        System.out.println(newLis);
    }

    /**
     * 通过属性值计算评分
     * @return
     */
    public long getGradeByAttr(Map<Integer,Integer> totalAttrMap){
        long grade = 0;
        for (int attr : totalAttrMap.values()){
            grade += attr;
        }
        return grade;
    }

    /**
     * 计算属性值 1固定加成 2百分比加成
     * @param attrMap
     * @param skill
     * @return
     */
    public Map<Integer,Integer> calTotalAttr(Map<Integer,Integer> attrMap,List<Integer> skill){
        if(skill == null ||skill.isEmpty()){
            return new HashMap<>(attrMap);
        }

        Map<Integer, Integer> addMap = getCalAttrMap();
        Map<Integer, Integer> percentageMap = getCalAttrMap();

        Map<Integer,Integer> resultAttr = new HashMap<>();

        for (int skillId:skill){
            HorseRunSkillConfig skillConfig = skillConfigs.get(skillId);
            if (skillConfig == null){
                continue;
            }
            int attributeType = skillConfig.getAttributeType();
            if (skillConfig.getType() == 1){
                addMap.put(attributeType,addMap.get(attributeType) + skillConfig.getSkillNum());
            }else if (skillConfig.getType() == 2){
                percentageMap.put(attributeType,percentageMap.get(attributeType) + skillConfig.getSkillNum());
            }
        }

        for (Map.Entry<Integer,Integer> entry:attrMap.entrySet()){
            int attrType =entry.getKey();
            int attrResult = BigDecimal.valueOf(entry.getValue() + addMap.get(attrType)).multiply(BigDecimal.valueOf(1000 + percentageMap.get(attrType))).divide(BigDecimal.valueOf(1000),2, RoundingMode.DOWN).intValue();
            resultAttr.put(attrType,attrResult);
        }

        return resultAttr;
    }

    /**
     * 拿一个空的属性map
     * @return
     */
    public Map<Integer,Integer> getCalAttrMap(){
        Map<Integer,Integer> map = new HashMap<>();
        map.put(eHorseRunAttrEnum.energy.getValue(),0);
        map.put(eHorseRunAttrEnum.artful.getValue(),0);
        map.put(eHorseRunAttrEnum.resistance.getValue(),0);
        return map;
    }

    /**
     * 随机一个卡片事件的卡片
     */
    public int randomCardEventCard(HorseRunEventConfig eventConfig){
        Map<Integer,Integer> weightMap = new HashMap<>();
        List<Integer> paramList = eventConfig.getParamList();
        paramList = paramList.subList(3,paramList.size());
        int cardId = 1;
        for (int weight: paramList){
            weightMap.put(cardId,weight);
            cardId++;
        }
        return WeightHelper.getRandomValue(weightMap);
    }

    /**
     * 随机一个经验事件
     */
    public HorseRunEventConfig randomExpEvent(){
        int eventId = WeightHelper.getRandomValue(expSignalEventWeightMap);
        return eventConfigs.get(eventId);
    }

    /**
     * 随机一个除经验 boss 探索子事件外的事件
     */
    public HorseRunEventConfig randomEvent (HorseRunUserGamingData gamingData){

        Map<Integer,Integer> weightMap = new HashMap<>();
        for (HorseRunEventConfig eventConfig:eventConfigs.values()){
            //三个不会正常出的不进
            if (eventConfig.getType() == eHorseRunEventType.exp.getValue()
                    ||eventConfig.getType() == eHorseRunEventType.bossBattle.getValue()
                    ||eventConfig.getType() == eHorseRunEventType.exploreChild.getValue()
                    ||eventConfig.getType() == eHorseRunEventType.startGame.getValue()
            ){
                continue;
            }

            //超出上限就不随机了
            if (eventConfig.getAllMax() > 0){
                if (gamingData.getEventMeetTime(eventConfig.getType())>= eventConfig.getAllMax()){
                   continue;
                }
            }
            if (eventConfig.getType() == eHorseRunEventType.simpleBattle.getValue()){
                if (gamingData.getProcessId() <= 0){
                    continue;
                }
            }
            if (eventConfig.getType() == eHorseRunEventType.addConfident.getValue()){
                if (gamingData.getNowConfident() >= gamingData.getMaxConfident()){
                    continue;
                }
            }
            weightMap.put(eventConfig.getId(),eventConfig.getWeight());
        }
        int eventId = WeightHelper.getRandomValue(weightMap);

        HorseRunEventConfig config = eventConfigs.get(eventId);
        if (config != null){
            gamingData.addEventTypeTime(config.getType(),1);
        }
        return config;

    }

    /**
     * 获取boss事件
     * @return
     */
    public HorseRunEventConfig getBossEvent(){
        for (HorseRunEventConfig config:eventConfigs.values()){
            if (config.getType() == eHorseRunEventType.bossBattle.getValue()){
                return config;
            }
        }
        return null;
    }

    /**
     * 获取随机技能
     * @return
     */
    public HorseRunSkillConfig getRandomSkill(){
        Map<Integer,Integer> weightMap = new HashMap<>();
        for (HorseRunSkillConfig HorseRunSkillConfig:skillConfigs.values()){
            weightMap.put(HorseRunSkillConfig.getId(),HorseRunSkillConfig.getWeight());
        }
        int randomValue = WeightHelper.getRandomValue(weightMap);
        return skillConfigs.get(randomValue);

    }

    /**
     * 获取技能刷新消耗道具个数
     * @return
     */
    public int getRefreshItemNum(int refreshTimes){
        if (refreshTimes == 0){
            return refreshCostItemAddMap.get(1);
        }
        refreshTimes = refreshTimes +1;
        int maxTime = 0;
        int maxNeed = 0;
        for (Map.Entry<Integer,Integer> entry : refreshCostItemAddMap.entrySet()){
            if (entry.getKey() > maxTime && refreshTimes >= entry.getKey()){
                maxTime = entry.getKey();
                maxNeed = entry.getValue();
            }
        }
        if (maxNeed <= 0 ){
            maxNeed = 1;
        }
        return maxNeed;
    }

    /**
     * 获取元宝刷新技能消耗元宝个数
     * @return
     */
    public int getRefreshIngotNum(int refreshTimes){
        if (refreshTimes == 0){
            return refreshIngotAddMap.get(1);
        }
        refreshTimes = refreshTimes +1;
        int maxTime = 0;
        int maxNeed = 0;
        for (Map.Entry<Integer,Integer> entry : refreshIngotAddMap.entrySet()){
            if (entry.getKey() > maxTime && refreshTimes >= entry.getKey()){
                maxTime = entry.getKey();
                maxNeed = entry.getValue();
            }
        }
        if (maxNeed <= 0 ){
            maxNeed = 1;
        }
        return maxNeed;
    }

    /**
     * 获取属性点刷新消耗道具个数
     * @return
     */
    public int getRefreshAttrCostNum(int refreshTimes){
        if (refreshTimes == 0){
            return refreshAttrPointCostAddMap.get(1);
        }
        refreshTimes = refreshTimes +1;
        int maxTime = 0;
        int maxNeed = 0;
        for (Map.Entry<Integer,Integer> entry : refreshAttrPointCostAddMap.entrySet()){
            if (entry.getKey() > maxTime && refreshTimes >= entry.getKey()){
                maxTime = entry.getKey();
                maxNeed = entry.getValue();
            }
        }
        if (maxNeed <= 0 ){
            maxNeed = 1;
        }
        return maxNeed;
    }

    /**
     * 通过商会总评级获取商会等级
     * @return
     */
    public int getLevelByUnionTotalGrade(long totalGrade){
        int maxLv = 1;
        for (HorseRunRaceCourseConfig courseConfig:courseConfigMap.values()){
            if (totalGrade >= courseConfig.getTotalNum() && courseConfig.getId() > maxLv){
                maxLv = courseConfig.getId();
            }
        }
        return maxLv;
    }

    /**
     * 根据赛区获取赛道分配配置
     * @return
     */
    public Map<Integer,List<Integer>> getRacingTrackDistribute(eHorseRunRacingZoneEnum zoneEnum){
        if (zoneEnum == null){
            return null;
        }
        if (zoneEnum == eHorseRunRacingZoneEnum.XuanWu){
            return getXuanWu4TrackDistributionMap();
        }else if (zoneEnum == eHorseRunRacingZoneEnum.ZhuQue){
            return getZhuQue3TrackDistributionMap();
        }else if (zoneEnum == eHorseRunRacingZoneEnum.BaiHu){
            return getBaiHu2TrackDistributionMap();
        }else if (zoneEnum == eHorseRunRacingZoneEnum.QingLong){
            return getQingLong1TrackDistributionMap();
        }
        return null;
    }


    public String getRefreshSkillItemCostAdd() {
        return refreshSkillItemCostAdd;
    }

    public Map<Integer, Integer> getRefreshCostItemAddMap() {
        return refreshCostItemAddMap;
    }

    public int getShowUnionHorseNum() {
        return showUnionHorseNum;
    }

    public Map<Integer, Integer> getTypeLimitMap() {
        return typeLimitMap;
    }

    public Map<Integer, Integer> getExpSignalEventWeightMap() {
        return expSignalEventWeightMap;
    }

    public int getRefreshSkillMaxTimesPosition() {
        return refreshSkillMaxTimesPosition;
    }

    public Map<Integer, Integer> getTurnTableWeightMap() {
        return turnTableWeightMap;
    }

    public int getRankMaxNum() {
        return rankMaxNum;
    }

    public long getRacingScoreByRank(int day,int rank){
        if (rank < 0){
            return 0;
        }
        List<UpLowLimitEntity> upLowLimitEntities = dayRacingScoreMap.get(day);
        if (upLowLimitEntities == null || upLowLimitEntities.isEmpty() ){
            int round = 1;
            for (int roundId : dayRacingScoreMap.keySet()){
                if (roundId > round){
                    round = roundId;
                }
            }
            upLowLimitEntities = dayRacingScoreMap.get(round);
        }
        if (upLowLimitEntities == null || upLowLimitEntities.isEmpty() ){
            return 0;
        }
        for (UpLowLimitEntity entity: upLowLimitEntities){
            if (entity.inRange(rank)){
                return entity.getValue();
            }
        }
        return 0;
    }

    public boolean canSign(){
        long now = System.currentTimeMillis();
        long todayZeroTimeStamp = DateHelper.getTodayZeroTimeStamp();
        List<Integer> openRacingTimeList = getOpenRacingTimeList();
        int startMin = openRacingTimeList.get(0);
        int endMin = openRacingTimeList.get(1);

        if ((todayZeroTimeStamp +(startMin * DateHelper.MINUTE_MILLIONS)) > now || todayZeroTimeStamp +(endMin * DateHelper.MINUTE_MILLIONS) < now){
            return false;
        }
        return true;
    }

    /**
     * 一天一轮 今天第几轮 从1开始
     * @return
     */

    public int getTodayRound(){
        return DateHelper.calc2DateTDOADays(new Date(activityInfo.getBeginTime() * 1000), new Date());
    }

    public String getRefreshIngotAdd() {
        return refreshIngotAdd;
    }

    public Map<Integer, Integer> getRefreshIngotAddMap() {
        return refreshIngotAddMap;
    }

    public int getRefreshAttrPointItem() {
        return refreshAttrPointItem;
    }

    public String getRefreshAttrCostAdd() {
        return refreshAttrCostAdd;
    }

    public Map<Integer, Integer> getRefreshAttrPointCostAddMap() {
        return refreshAttrPointCostAddMap;
    }

    /**
     * 获取开始游戏事件
     */
    public HorseRunEventConfig getStartGameConfig() {
        for (HorseRunEventConfig eventConfig:eventConfigs.values()){
            if (eventConfig.getType() == eHorseRunEventType.startGame.getValue()){
                return eventConfig;
            }
        }
        return null;
    }

    public int getRacingRoadTotalNum() {
        return racingRoadTotalNum;
    }

    public int getOpenDiffRoadNeedTimeTime() {
        return openDiffRoadNeedTimeTime;
    }

    public int getRacingChooseResetTime() {
        return racingChooseResetTime;
    }

    public List<Integer> getNeedRecycleItemList() {
        return needRecycleItemList;
    }
}
